% Quick script to calculate the swirling strenght of individual fields
%
% Julio Barros
% UIUC - 2010

clear
close
clc

if ispc == 1
    slash = '\';
else
    slash = '/';
end

folder = uigetdir('Folder: ','s');
files = dir([folder slash '*.vec']);
if isempty(files) == 1
    files = dir([folder slash '*.dat']);
end

for i=1:length(files)
    
    pathfile = [folder slash files(i).name];
    [nc,I,J,Dx,Dy,X,Y,U,V] = matrix(pathfile);
    
    [VorticityZ] = curl( X , Y , U , V );
    lambdaci = SwirlingStrength(Dx,Dy,U,V,VorticityZ);
    
    
    if ispc ==1
        slash = '\';
    else
        slash = '/';
    end
    
    Umix = mixing(I,J,X,Y,U,V,lambdaci);
    Umix = sortrows(Umix,[2,1]);
    
    vecfile = files(i).name;
    title = strcat('VARIABLES= "X", "Y", "U", "V", "lambdaci", ZONE',' I=',num2str(I),' J=',num2str(J),' F=POINT');
    saver(folder,[slash vecfile(1:end-4) '_swirl.dat'],title,Umix)
    
end




